﻿@using GridMvc.Site.Models

<div class="code-cut">
    <a href="javascript:void(0);" class="code-toggle">Show code to build this grid</a>
    <pre class="brush: razor">
    @@Html.Grid(Model).Columns(columns =>
    {
        /* Adding not mapped column, that renders body, using inline Razor html helper */
        columns.Add()
                .Encoded(false)
                .Sanitized(false)
                .SetWidth(30)
                .RenderValueAs(d =>
                    @@<b>
                        @@Html.ActionLink("Edit", "Index")
                    </b>);

        /* Adding "OrderID" column: */
        columns.Add(o => o.OrderID)
                .Titled("Number")
                .SetWidth(100);

        /* Adding "OrderDate" column: */
        columns.Add(o => o.OrderDate, "OrderCustomDate")
                .Titled("Date")
                .SortInitialDirection(GridSortDirection.Descending)
                .Format("{0:dd/MM/yyyy}")
                .SetWidth(110);

        /* Adding "CompanyName" column: */
        columns.Add(o => o.Customer.CompanyName)
                .Titled("Company Name")
                .ThenSortByDescending(o => o.OrderID)
                .SetFilterWidgetType("CustomCompanyNameFilterWidget");

        /* Adding "Vip customer" column: */
        columns.Add(o => o.Customer.IsVip)
                .Titled("Vip customer")
                .SetWidth(150)
                .RenderValueAs(o => CustomRenderingOfColumn(o));

    }).SetRowCssClasses(item => item.Customer.IsVip ? "warning" : string.Empty).WithPaging(15).Sortable().Filterable().WithMultipleFilters()
    </pre>
</div>